package findDifference;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Solution {
    public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {
        List<List<Integer>> ans = new ArrayList<>();
        ans.add(new ArrayList<>());
        ans.add(new ArrayList<>());
        Set<Integer> set1 = new HashSet<>();
        Set<Integer> set2 = new HashSet<>();
        for (int n: nums1) {
            set1.add(n);
        }
        for (int n: nums2) {
            set2.add(n);
        }
        for (int s1: set1) {
            if(!set2.contains(s1)) {
                ans.get(0).add(s1);
            }
        }
        for (int s2: set2) {
            if(!set1.contains(s2)) {
                ans.get(1).add(s2);
            }
        }
        return ans;
    }
}
